/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.unipampa.utilitarios;

import br.unipampa.view.FrameAlarme;
import java.util.ArrayList;

/**
 *
 * @author gabrielbmoro
 */
public class TrataAlarme {
    /*posições pares horários, ímpares compromissos*/
    private static TrataAlarme trataAlarme=null;
    private ArrayList<String> horarioCOmpromisso;
    private String data;
    private FrameAlarme frameAlarme;
    public static boolean BOOL;
    
    private TrataAlarme() {
        this.horarioCOmpromisso = new ArrayList<>();
        this.BOOL= false;
    }

    public static TrataAlarme getInstance(){
        if(trataAlarme==null){
            trataAlarme= new TrataAlarme();
        }
        return trataAlarme;
    }
    public void addHorarioCompromisso(String hora, String compromisso) {
        if (hora != null && compromisso != null) {
            this.horarioCOmpromisso.add(hora);
            this.horarioCOmpromisso.add(compromisso);
        } else {
            return;
        }
    }
    
    public void alterarCompromisso(String hora, String compromisso){
        int x=0;
        for(;x<this.horarioCOmpromisso.size();x++){
            if(x%2!=0){
                 continue;
            }else{
                if(this.horarioCOmpromisso.get(x).equals(hora)){
                    this.horarioCOmpromisso.set(x+1, compromisso);
                }
            }
        }
    }

    public void monitorar(String hora) {
        int x = 0;
        for (; x < this.horarioCOmpromisso.size(); x++) {
            if (x % 2 != 0) {
                continue;
            } else {
                /*EM CONSTRUÇÃO*/
                if (this.horarioCOmpromisso.get(x).equals(hora)) {
                    if (this.frameAlarme == null) {
                        if(this.BOOL==false){
                        this.frameAlarme = new FrameAlarme();
                        this.frameAlarme.getLblCompromisso().setText(this.horarioCOmpromisso.get(x + 1));
                        this.frameAlarme.getLblHorarioEData().setText(this.horarioCOmpromisso.get(x));
                        this.frameAlarme.setVisible(true);
                        this.BOOL= true;
                       }
                    }
                }
                /*EM CONSTRUÇÃO*/
            }
        }
    }

    public void setHorarioCompromissoDiario(ArrayList<String> horarioCOmpromisso) {
        this.horarioCOmpromisso = horarioCOmpromisso;
    }

    public String getData() {
        return this.data;
    }

    public void setData(String data) {
        this.data = data;
    }

}
